# $Id$
# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>
# I had to obtain the latest from git because 2.10 does not work well with Win64
_realname=libsigsegv
pkgbase=mingw-w64-${_realname}-git
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=496.95dc411
pkgrel=1
arch=(any)
pkgdesc='Page fault detection library (git) (mingw-w64)'
url='https://www.gnu.org/software/libsigsegv/'
license=('GPL2')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepend=('git')
source=("${_realname}"::"git+https://git.savannah.gnu.org/git/libsigsegv.git#branch=master"
        "fix-win64.patch")
sha256sums=('SKIP'
            '79e2da894c70136e2805d28177bc632cc0ae18905e3bfcdd92c52421ea1bb7bd')

pkgver() {
  cd "${srcdir}"/${_realname}
  printf "%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd $srcdir/${_realname}
  patch -Np1 -i "${srcdir}"/fix-win64.patch
  autoreconf -fiv
}


build() {
  cd $srcdir/${_realname}
  [[ -d ${srcdir}/build-${CARCH} ]] && rm -rf ${srcdir}/build-${CARCH}
  mkdir -p ${srcdir}/build-${CARCH} && cd ${srcdir}/build-${CARCH}
  ../${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    CPPFLAGS="-I${MINGW_PREFIX}/include -Wall" \
    LDFLAGS="-L${MINGW_PREFIX}/mingw32/lib"
  make
}

check() {
  cd ${srcdir}/build-${CARCH}
  make check || true
}


package() {
  cd ${srcdir}/build-${CARCH}
  make DESTDIR="${pkgdir}" install
}
